<template>
    <div>
        <div class="data-content1">
            <el-table v-loading="loading" :data="tableData.list" @sort-change="changeTableSort"
                style="width: 100%;font-size: 12px;">
                <el-table-column label="流水号" sortable="custom" prop="no" width="120">
                </el-table-column>
                <el-table-column label="交易前余额" sortable="custom" prop="preAmount" width="120">
                </el-table-column>
                <el-table-column label="交易金额" sortable="custom" prop="money" width="120">
                </el-table-column>
                <el-table-column label="交易后余额" sortable="custom" prop="afterAmount" width="120">
                </el-table-column>
                <el-table-column label="账号名称" prop="name" width="120">
                </el-table-column>
                <el-table-column label="创建时间" prop="date" width="160">
                </el-table-column>
                <el-table-column label="备注" prop="note">
                </el-table-column>
            </el-table>

            <div class="page">
                <el-pagination background :current-page="searchObject.no" :page-sizes="[10, 20, 50, 100]"
                    :page-size="tableData.size" :pager-count="5" layout="total, sizes, prev, pager, next, jumper"
                    :page-count="tableData.totalPage" :total="tableData.total" @size-change="sizeChange"
                    @current-change="pageChange">
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
    import common from "@/mixins/common.js";
    var config = {};
    config.methods = {};
    config.mixins = [common];

    config.methods.changeTableSort = function (column) {
        this.searchObject.sortField = column.prop;
        if ("descending" == column.order) {
            this.searchObject.sortMethod = "desc";
        } else if ("ascending" == column.order) {
            this.searchObject.sortMethod = "asc";
        } else {
            this.searchObject.sortMethod = "";
        }
        this.getSearchList();
    }
    config.methods.show = function (row) {
        var param = {};
        param.id = row.id;
        this.$router.push({
            path: 'view',
            query: param
        });

    }
    config.methods.sizeChange = function (event) {
        this.searchObject.size = event;
        this.getSearchList();
    }
    config.methods.pageChange = function (index) {
        this.searchObject.no = index;
        this.getSearchList();
    }
    config.methods.getSearchList = function () {
        this.loading = true;
        var data = this.searchObject,
            that = this;
        this.postData("/tenantRest/tenantaccount/stream.htm", data, function (result) {
            if (result.code == 0) {
                that.tableData = result;
            }
            setTimeout(function () {
                that.loading = false;
            }, 300)
        });
    }
    config.methods.search = function () {
        this.searchObject.no = 1;
        this.getSearchList();
    }
    config.methods.clearData = function () {
        this.searchObject.key = "";
        this.searchObject.account = "";
    }
    config.methods.deleteData = function (event) {
        this.selectId = event.id;
        this.dialogVisible = true;
    }


    config.computed = {};

    config.data = function () {
        return {
            searchObject: {
                no: 1,
                size: 10,
                id: '',
            },
            dialogVisible: false,
            defaultProps: {
                children: 'children',
                label: 'name'
            },
            loading: false,
            tableData: {},
        }
    };
    config.mounted = function () {
        var id = this.$route.query.id;
        this.searchObject.id = id;
        this.getSearchList();
    }

    export default config;
</script>

<style scoped>

</style>